﻿using NFine.Application.BusinessManage;
using NFine.Code;
using NFine.Domain.Entity.BusinessManage;
using System.Web;
using System.Web.Mvc;

namespace NFine.Web.Areas.BusinessManage.Controllers
{
    public class D_NewsListController : ControllerBase
    {
        private D_NewsListApp newsListApp = new D_NewsListApp();

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = newsListApp.GetList(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }


        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGrid(string keyword)
        {
            var data = newsListApp.GetGrid(keyword);
            return Content(data.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = newsListApp.GetForm(keyValue);
            return Content(data.ToJson());
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public ActionResult SubmitForm(D_NewsListEntity newsListEntity, string keyValue)
        {
            newsListEntity.F_Content = System.Uri.UnescapeDataString(newsListEntity.F_Content);
            newsListApp.SubmitForm(newsListEntity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            newsListApp.DeleteForm(keyValue);
            return Success("删除成功。");
        }

        [HttpGet]
        public ActionResult Content()
        {
            return View();
        }

    }
}
